<?php

require 'utilsBD.php';
require 'utils.php';

$q = strtolower($_GET["q"]);
if (!$q) return;
$tab_q = explode(' ', $q);
$dim = count($tab_q);
$last_word = $tab_q[$dim-1];


if($last_word != ''){
    connect();
    $requete = "SELECT * FROM `Tag` WHERE tag like \"{$last_word}%\";";
    $reponse = executerRequete($requete, $GLOBALS['debug']);
    while ($row = mysql_fetch_array($reponse)) {
        $tab_q[$dim-1] = $row['tag'];
        echo implode('|', $tab_q)."\n";
    }
    mysql_close();
}


?>
